/*
 * vs1011_e.h
 *
 * Created: 04.01.2012 21:51:59
 *  Author: Luke
 */ 


#ifndef VS1011E_H_
#define VS1011E_H_

//This defines a 32-bit register IO packet for the VS 1011
struct  
{
    uint8_t  opcode;
    uint8_t  adress;
    uint16_t data;
} vs_packet_t;

//must be a multiple of 32!
#define BUFFERSIZE 512

uint8_t playback_buffer_[BUFFERSIZE];
uint16_t buffer_pos_;

//sets up the VS1011 I/O lines
void vsInit(void);

// (re)Sets the VS chip select lines on the MCU, according to the
// settings in vs1011_defs.h
void vsChipSelect();
void vsChipDeSelect();
void vsChipSelectD();
void vsChipDeSelectD();

// (re)Sets the VS HW reset line on the MCU, according to the
// settings in vs1011_defs.h
void vsReset();
void vsUnReset();

// starts the sine test (single tone output) according to
// data sheet page 38 (9.7.1 Sine Test). default frequency: 5168Hz (126)
void vsSineTest(void);

// Reads/Writes the SCI Registers. Register names are available from
// vs1011_regs.h and are correspond to the vs1011 datasheet.
void vsWriteRegister(uint8_t reg_addr, uint16_t reg_data);
uint16_t vsReadRegister(uint8_t reg_addr);

uint8_t vsGetDREQ(void);

void vsPrepPlay(void);
void vsPlayBuffer(void);

#endif /* VS1011E_H_ */